package com.ilink.teacherservice.service.impl.bailian;

import com.aliyun.bailian20231229.models.SubmitIndexAddDocumentsJobResponse;
import com.aliyun.tea.TeaException;


import com.ilink.teacherservice.service.bailian.SubmitIndexAddDocumentsJobService;
import java.util.List;
import org.springframework.stereotype.Service;

@Service
public class SubmitIndexAddDocumentsJobServiceImpl implements SubmitIndexAddDocumentsJobService {
    /**
     * 返回格式
     *{
     *   "Status": 200,
     *   "RequestId": "20BDFCD4-D06A-5477-9E58-09ACBB4290A1",
     *   "Message": "success",
     *   "Data": {
     *     "Id": "1e536d3a66e94e1aa82ab5ffecfd5db2"
     *   },
     *   "Code": "Success",
     *   "Success": true
     * }
     **/
    @Override
    public SubmitIndexAddDocumentsJobResponse submitIndexAddDocumentsJob(com.aliyun.bailian20231229.Client client, String workspaceId, String indexId, List<String> documentIds) throws Exception {
        com.aliyun.bailian20231229.models.SubmitIndexAddDocumentsJobRequest submitIndexAddDocumentsJobRequest = new com.aliyun.bailian20231229.models.SubmitIndexAddDocumentsJobRequest()
                .setIndexId(indexId)
                .setSourceType("DATA_CENTER_FILE")
                .setDocumentIds(documentIds);
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        java.util.Map<String, String> headers = new java.util.HashMap<>();
        try {
            // 复制代码运行请自行打印 API 的返回值
            return client.submitIndexAddDocumentsJobWithOptions(workspaceId, submitIndexAddDocumentsJobRequest, headers, runtime);
        } catch (TeaException error) {
            // 此处仅做打印展示，请谨慎对待异常处理，在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
            throw new TeaException(error.getMessage(), error);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // 此处仅做打印展示，请谨慎对待异常处理，在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
            throw new Exception(error.getMessage());
        }
    }

    @Override
    public SubmitIndexAddDocumentsJobResponse submitIndexAddCategoryJob(com.aliyun.bailian20231229.Client client, String workspaceId, String indexId, List<String> categoryIds) throws Exception {
        com.aliyun.bailian20231229.models.SubmitIndexAddDocumentsJobRequest submitIndexAddDocumentsJobRequest = new com.aliyun.bailian20231229.models.SubmitIndexAddDocumentsJobRequest()
                .setIndexId(indexId)
                .setSourceType("DATA_CENTER_CATEGORY")
                .setCategoryIds(categoryIds);
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        java.util.Map<String, String> headers = new java.util.HashMap<>();
        try {
            // 复制代码运行请自行打印 API 的返回值
            return client.submitIndexAddDocumentsJobWithOptions(workspaceId, submitIndexAddDocumentsJobRequest, headers, runtime);
        } catch (TeaException error) {
            // 此处仅做打印展示，请谨慎对待异常处理，在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
            throw new TeaException(error.getMessage(), error);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // 此处仅做打印展示，请谨慎对待异常处理，在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
            throw new Exception(error.getMessage());
        }
    }
}
